﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NMLX_Data_Management
{
    public partial class AddProject : Form
    {       

        public AddProject()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text.ToString())|| string.IsNullOrEmpty(textBox2.Text.ToString()))
            {
                return;
            }

            var p = AppDomain.CurrentDomain.BaseDirectory + "\\NMLX_Projects\\" + textBox1.Text.ToString();
            Directory.CreateDirectory(p);
            string projectName = textBox1.Text.ToString();
            string projectcode = textBox2.Text.ToString();

            string sql =string.Format("insert into project (proname,code) values ('{0}','{1}')", projectName, projectcode);
            try
            {
                NMLX.DBUtility.DbHelperOleDb.ExecuteSql(sql);
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
                return;
            }          

            this.Close();
           
            
           
        }

        private void AddProject_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }
    }
}
